package demo.IOInputOutput;

import java.io.*;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/12-08-12-15:14
 * @Description：demo.IOInputOutput
 */
public class File_package_Stream {
    public static void main(String[] args) {
        DataOutputStream dos = null;
        DataInputStream dis = null;

        try {
            dos = new DataOutputStream(new FileOutputStream("hello.txt"));
            dos.writeLong(1000l);
            dos.writeUTF("hello");

            dis = new DataInputStream(new FileInputStream("hello.txt"));
            System.out.println(dis.readLong());
            System.out.println(dis.readUTF());

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                dos.close();
                dis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
